<template>
  <div>
      <h1>登录页面</h1>
      <p>请输入用户名: <input type="text" v-model="username"></p>
      <p>请输入密码: <input type="password" v-model="password"></p>
      <p><input type="button" value="登录" @click="btn"></p>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
            username:"",
            password:"",
        }
    },
    methods: {
        btn(){
            axios.post("http://127.0.0.1:8000/app1/login/",{"username":this.username,"password":this.password}).then(resp=>{
                console.log(resp.data)
                if(resp.data.code==200){
                    sessionStorage.setItem("username",this.username)
                    sessionStorage.setItem("uid",resp.data.uid)
                    this.$router.push("/index")
                }
            })
        }
    },
}
</script>

<style>

</style>